public class Ellipse extends Rectangle
{
    public Ellipse()
    {
        super();
        this.shape="椭圆";
    }

    public Ellipse(Point p1,Point p2)
    {
        super(p1,p2);
        this.shape="椭圆";
    }

    public Ellipse(Point p1,double length,double width)
    {
        super(p1,length,width);
        this.shape="椭圆";
    }

    public Ellipse(Ellipse r)
    {
        super(r);
        this.shape="椭圆";
    }

//    public String toString()
//    {
//        return "Ellipse{"+
//                "shape='"+shape+'\''+
//                ", point1="+point1+
//                ", length="+length+
//                ", width="+width+
//                '}';
//    }

    public String toString()
    {
        return "new Ellipse("+point1+","+length+","+width+")";
    }

    public double perimeter()
    {
        return Math.PI*length+2*(length-width);
    }

    public double area()
    {
        return Math.PI*width*length/4;
    }

    public boolean contains(Point p)
    {
        double a=length/2;
        double b=width/2;
        double x=p.getX()-(point1.getX()+a);
        double y=p.getY()-(point1.getY()+b);
        return MyMath.compareDouble(x*x/a/a+y*y/b/b,1)<=0;
    }
}
